package JAVA300.第十一章多线程;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 阻塞状态sleep
 * 模拟日期倒计时
 */
public class thread_11_threadState_blocked2_sleep {
    public static void main(String[] args) throws InterruptedException {

        Date enddate = new Date(System.currentTimeMillis()+1000*10);
        long end = enddate.getTime();//用于判断结束
        while (true){
            System.out.println(new SimpleDateFormat("mm:ss").format(enddate));
            Thread.sleep(1000);//每隔1s 日期改变
            enddate = new Date(enddate.getTime()-1000);
            //结束判断
            if (end - 10000 > enddate.getTime()){
                break;
            }


        }

    }
}


